<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@page import="com.crm.entity.Opportunity,com.crm.entity.Supplier,java.util.*" %>
<head>
<link href="<%=application.getContextPath()%>/css/css-crm.css" rel="stylesheet" type="text/css" />



<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery-1.7.2.min.js"></script>
<script language="javaScript" src="<%=application.getContextPath()%>/js/jquery-ui-1.8.20.custom.min.js"></script>
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery-1.6.min.js"></script>	
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery-ui-1.8.17.custom.min.js"></script>	
<link rel="stylesheet" href="<%=application.getContextPath()%>/css/jquery-ui-1.8.17.custom.css"/>
	
<script language="JavaScript" src="<%=application.getContextPath()%>/js/gen_validatorv4.js" type="text/javascript" ></script>
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery.validate.js"></script>
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery.validate.min.js"></script>	
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />


<link href="<%=application.getContextPath()%>/css/css-crm.css" rel="stylesheet" type="text/css" />


<script type="text/javascript">
function quotclick(){
	var refid=$('#reflistid option:selected').val();
	if((refid==null)||(refid=="")){
		jAlert("Please Select Refrence Number");
		return false;
	}
	else{
	var data="refno="+refid;
	$("#ajaxLoader").show();
	
	$.ajax({
		url:"<%=application.getContextPath()%>/newquot/getquot.do",
		mimetype: "text/html",
		method: "post",
		data:data,
		cache:false,
		success: function(res){
			$('#quotdiv').html(res);
			}
		}).done(function(html){
			$("#ajaxLoader").hide();
			/* alert("Ajax Loading Completed"); */
		}).fail(function(html){
			$("#ajaxLoader").hide();
			alert("Failed To Load the Data");
		});
	}
}
$(function(){
	var refid=$('#reflistid option:selected').val();
	if((refid==null)||(refid=="")){
		//jAlert("Please Select Refrence Number");
		return false;
	}
	else{
	var data="refno="+refid;
	$("#ajaxLoader").show();
	
	$.ajax({
		url:"<%=application.getContextPath()%>/newquot/getquot.do",
		mimetype: "text/html",
		method: "post",
		data:data,
		cache:false,
		success: function(res){
			$('#quotdiv').html(res);
			}
		}).done(function(html){
			$("#ajaxLoader").hide();
			/* alert("Ajax Loading Completed"); */
		}).fail(function(html){
			$("#ajaxLoader").hide();
			alert("Failed To Load the Data");
		});
	}
});



    </script>
    
    
</head>
<body>
<%List<Opportunity> opprtlist =(List<Opportunity>)request.getAttribute("opprtunity");%>
<div id="main">
   <%@ include file="common/header.jsp" %>
  <%@ include file="common/submenu.jsp" %>
  <div id="content">
   <div id="resultMsg" class="result_msg">
    <% 
   String msg= request.getParameter("msgsrc");
    String curref= request.getParameter("currentref");
    System.out.println("the current frefrence is"+curref);
    	if(msg!=null){
    		System.out.println(msg);
    		out.println(msg);
    	}
    	
    %>
    </div>
    <div id="enqclient" style="display: none;" align="center" class="result_msg">

    </div>
    <div id="oppId" style="display:none">
    <table>
    <tr>
    <td>Opportunity Name:</td>
    <td id="oppname"></td>
    <td>User:</td>
    <td id="userName"></td>
    <td>Lab:</td>
    <td id="lab"></td>
    </tr>
    </table>
    </div>
  <form id="impform" name="impform"  action="<%=application.getContextPath()%>/newquot/quotsave.do"   method="post">
    <div id="work-area2">
      <div class="heading2">New Quotations</div>
	  
      <div class="boxIFS">
         <table width="100%"  id="validtab" border="0" style="height:80px;"  cellspacing="0" cellpadding="0">
          <tr>
            <td width="500" align="left" valign="middle">
            <table width="500" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="right"  width=40%" valign="middle">Reference Number </td>
                <td align="center" width="50%" valign="top">
                <select name="reflist"  id="reflistid"  class="form_select" id="reflist"  >
                
                 <option value="">Select Refrence</option>
         <% 
              if(opprtlist!=null){
            	  System.out.println("the size of the pr list is "+opprtlist.size());
	      	for(int i=0;i<opprtlist.size();i++){
	      	%>
           <option   <%if(curref!=null && curref.equals(opprtlist.get(i).getRefNum())){ %>selected="selected" <%} %>  value="<%=opprtlist.get(i).getRefNum()%>"><%=opprtlist.get(i).getRefNum()%></option>
                   	<%	}
	              	}%>
                </select></td>
              </tr>
        </table></td>
         
              <td width="300" align="left" valign="middle">
            <table width="300" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="left" valign="middle"> <input  class="buttonleft" type="button"  onclick="javascript: return quotclick();" value="Set Quotation"/></td>
                <td align="left" valign="middle"></td>
              </tr>
            </table></td>
          </tr>
        </table>
          
      </div>
      <div id="ajaxLoader" style="display:none" align="center"><img src="<%=application.getContextPath()%>/images/ajax_loader.gif"/></div>
      <table style="height:300px; width:910px;" ><tr><td><div id="quotdiv" ></div></td></tr></table> 
    </div>
    </form>
    <!-- InstanceEndEditable -->
  </div><div id="footer"></div>  
</div>
</body>
<!-- InstanceEnd --></html>

<script language="JavaScript" type="text/javascript"><!--
function processFormData(){
	 var tc=$("#tc").val();
	  if(tc==0){
		  jAlert("Please Check the Terms And Conditions");
		  return false;
	  }
  var frmvalidator  = new Validator("impform");
  
  var rowcount=document.getElementById("rowcountid");
  var rowc=rowcount.value;
//alert("the rowcount value is"+rowc);
  for(var i=1;i<=rowc;i++)
	  {
  //frmvalidator.addValidation("partno"+i,"req","Please enter PartNo"+i+"");
  /* frmvalidator.addValidation("partno"+i,"maxlen=30",	"Max length for partno"+i+" is 30");
  frmvalidator.addValidation("partno"+i,"alphanumeric","partno"+i+"Only alpha and Numeric chars only"); */
  
  frmvalidator.addValidation("make"+i,"req","Please enter made by"+i);
 /*  frmvalidator.addValidation("make"+i,"maxlen=30","Max length of made by"+i+"is 30 "); */
  
  frmvalidator.addValidation("required"+i,"req","Please enter Required"+i+" Quantity");
  frmvalidator.addValidation("required"+i,"numeric","Please RequiredQuantity"+i+" must be numeric");
  
  frmvalidator.addValidation("source"+i,"req","source"+i+" must not be empty");
    frmvalidator.addValidation("source"+i,"maxlen=50","maximum  length of source"+i+" is 50");
  /*   frmvalidator.addValidation("source"+i,"alphabetic_space","Source"+i+" must be characters"); */
    
  frmvalidator.addValidation("supplier"+i,"req","supplier"+i+" must not be empty");
/*   frmvalidator.addValidation("supplier"+i,"alphabetic_space"); */
  
  frmvalidator.addValidation("uvalue"+i,"req","unit price must not be empty");
  frmvalidator.addValidation("uvalue"+i,"numeric","Unit value should be number");
  
  frmvalidator.addValidation("fright"+i,"req","fright"+i+" must not be empty");
  frmvalidator.addValidation("fright"+i,"numeric","fright"+i+" value must be numeric");
 
  
  frmvalidator.addValidation("assesable"+i,"req","Assesable"+i+" must not be empty");
  frmvalidator.addValidation("assesable"+i,"numeric","Assesable"+i+" must be numeric");
  
  frmvalidator.addValidation("bcd"+i,"req"," BCD"+i+"must not be empty");
  frmvalidator.addValidation("bcd"+i,"numeric","BCD"+i+" must be numeric");
  
/*   frmvalidator.addValidation("stot"+i,"req","Sub Total"+i+" must not be empty"); */
  frmvalidator.addValidation("stot"+i,"numeric","Sub Total"+i+" must be numeric");
  
  frmvalidator.addValidation("margin"+i,"req","Margin"+i+"must not be empty");
  frmvalidator.addValidation("margin"+i,"numeric","Margin"+i+" must be numeric");
  
  frmvalidator.addValidation("quotprice"+i,"req","Quotation"+i+" price must not be empty");
  frmvalidator.addValidation("quotprice"+i,"numeric","Quotation"+i+" must be numeric");
  
 	
	  }
}
</script>